package com.open.capacity.notice.validator;

import org.springframework.util.ObjectUtils;

import com.open.capacity.notice.context.SendMessageJobContext;

import net.bytebuddy.matcher.ElementMatcher;

public class TemplateChecker implements ElementMatcher<SendMessageJobContext> {

	@Override
	public boolean matches(SendMessageJobContext contex) {
		if (ObjectUtils.isEmpty(contex.getMessageTemplate())) {
			contex.setMsg("无效的发送模板");
			return false;
		}
		return true;
	}

	// 匿名内部类，确保只有在第一次访问时才会被初始化
	private static class Holder {
		private static final TemplateChecker INSTANCE = new TemplateChecker();
	}

	public static TemplateChecker getInstance() {
		return Holder.INSTANCE;
	}
}
